package util

import (
	"fmt"
	"io"
)

func ReadCloserToString(read io.ReadCloser) string {
	buff := make([]byte, 4096)
	result := make([]byte, 4096)
	for {
		n, err := read.Read(buff)
		if err != nil {
			if err == io.EOF {
				break
			} else {
				fmt.Printf("Read error：%s", err)
				break
			}
		}
		if n == 0 {
			fmt.Printf("Read finish")
			break
		}
		result = append(result, buff...)
	}
	return string(result)
}
